package cn.itcast.order;

import cn.itcast.feign.api.UserFeign;
import cn.itcast.feign.config.DefaultFeignConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
//@EnableFeignClients
@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration.class, basePackages = "cn.itcast.feign.api")
//@EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration.class, clients = {UserFeign.class})

public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    @Bean
    @LoadBalanced //RestTemplate实例将可以去eureka-server中拉取user-service服务的实例列表，并且实现负载均衡(基于Ribbon负载均衡器)
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
